package com.example.ticketorder.repository.dao;

import com.example.ticketorder.entity.Ticket;
import com.example.ticketorder.repository.TicketRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.validation.Valid;
import java.sql.Date;
import java.sql.Time;

@Repository
public class TicketDao {
    @Autowired
    @Qualifier("ticketRepository")
    private TicketRepository ticketRepository;
    //@Valid
    public Iterable<String> findDestination(){
        return ticketRepository.findDestination();
    }
    public String findDest(String car,String departure){
        return ticketRepository.findDest(car,departure);
    }
    public Iterable<String> findCar(){
        return ticketRepository.findCar();
    }
    public Iterable<String> findDTime(){
        return ticketRepository.findDTime();
    }
    public int findPool(String car){
        return ticketRepository.findPoll(car);
    }
    public int findZpoll(String car,String departure){
        return ticketRepository.findZpoll(car,departure);
    }
    public double findMoney(String car,String destination){
        return ticketRepository.findMoney(car,destination);
    }
    public Iterable<String> findScar(String destination, Date Dtime){
        return ticketRepository.findScar(destination,Dtime);
    }
    public Iterable<String> findSite(String car,String departure){
        return ticketRepository.findSite(car,departure);
    }
    public Iterable<String> findDeparture(String car,Time Htimeb){
        return ticketRepository.findDeparture(car,Htimeb);
    }
    public Iterable<String> findZcar(String departure,Time Htimea,String car){
        return ticketRepository.findZcar(departure,Htimea,car);
    }
    public Iterable<Ticket> findAll() {
        return ticketRepository.findAll();
    }
    public Time findHtimea(String car, String departure){
        return ticketRepository.findHtimea(car,departure);
    }
    public Time findHtimeb(String car,String destination){
        return ticketRepository.findHtimeb(car,destination);
    }
    public Time findZHtimeb(String destination,String car){
        return ticketRepository.findZHtimeb(destination,car);
    }

    //更改数据
    public void updatePoll(String car,String departure){
        ticketRepository.updatePoll(car,departure);
    }
    public void updatePollq(String car,String departure){
        ticketRepository.updatePollq(car,departure);
    }
}
